package keyboard.service;

import keyboard.dao.UserMapper;
import keyboard.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 2B键盘
 * @create 2018-05-03 13:27
 * @desc
 **/
@Service
@Transactional
public class UserService {

    @Autowired
    UserMapper mapper;

    /**
     * 添加一个新用户
     * @param user
     * @return
     */
    public int addUser(User user){
        return mapper.insert(user);
    }
    /**
     * 登陆
     */
    public User login(User user){
        return mapper.login(user);
    }
    /***
     * 查询用户 by id
     */
    public int getUserId(String identity){
        User user = new User();
        user.setIdentity(identity);
        return mapper.selectByIdentity(user).getId();
    }

}
